angular.module('app').controller('addPostCtrl', 
['$scope', '$rootScope', 'http',
function($scope, $rootScope,http) 
{	
	$scope.post = { name:'',
					codes:'',
					oldprice:'',
					price:'',
					type:'',
					tag:'',
					hot:'',
					version:'',
					demo:'',
					download:'',
					credate:'',
					modate:'',
					title:'',
					imgs:'',
					codeyuan:'',
					postlog:'',
					details:'',
					desc:'',
					status:'1'
	};
	// 新增商品
	$scope.addPost = function(){
		if(''==$scope.post.details ||!angular.isObject(JSON.parse($scope.post.details))){
			alert("商品详细信息文本格式错误或不能为空")
			return false;
		}
		if(!angular.isObject(JSON.parse($scope.post.size))){
			alert("商品规格文本格式错误或不能为空")
			return false;
		}
		if(!angular.isObject(JSON.parse($scope.post.imgs))){
			alert("商品详细信息文本格式错误或不能为空")
			return false;
		}
		var reqUrl = globalConfig.web + '/posts/add';
		http.post(reqUrl, $scope.post, function(data, status){
			if(data.status==200){
				alert(data.msg);
			}
			if(data.status==500){
				alert(data.msg);
			}
		})
	}

	
}]);